package org.example.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
public class RabbitConfig {

    public static final String QUEUE = "demo-queue";
    public static final String EXCHANGE = "demo-exchange";
    public static final String ROUTING = "demo.routing.#";

    // 声明交换机、队列、绑定关系（Spring Boot 3 自动创建）
    @Bean
    public Declarables declarables() {
        Queue queue = new Queue(QUEUE, true);
        TopicExchange exchange = new TopicExchange(EXCHANGE, true, false);
        Binding binding = BindingBuilder
                .bind(queue)
                .to(exchange)
                .with(ROUTING);
        return new Declarables(queue, exchange, binding);
    }
}